/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.ace.dao;
import  com.ace.model.bo.IMetier;

/**
 *
 * @author a.kanwar
 * class factory contenant les méthodes pour récuperer la dao d'une class métier de facon génerique.
 */
public class FactoryDao {

    public static IDao<?> getDAO(IMetier objet) 
    {
        String className = "com.ace.dao.Dao" + objet.getClass().getSimpleName();
        Class<?> cl;
        Object o = null;

        try
        {
            cl = Class.forName(className);
            o = cl.newInstance();
        } 
        catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) 
        {
            e.printStackTrace();
        }
        return (IDao<?>) o;
    }
    
    public static IDao<?> getDAO(String classe) 
    { 
       String className = "com.ace.dao.Dao"+classe;
       Class<?> cl;
       Object o = null;

        try 
        {
            cl = Class.forName(className);
            o = cl.newInstance();

        } 
        catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) 
        {
            e.printStackTrace();
        }
        return (IDao<?>) o;
    }
}
